package com.bloveoa.zkkd.redis.utils;


import javax.validation.constraints.NotNull;

/**
 * redis key 生成器
 *
 * @author lihe
 */
public class RedisKeyGenerator {

    private static final String BASE_KEY = "smc";

    private static final String PUBLIC_BASE_KEY = "sc:p:";


    public static String genTokenCacheKey(@NotNull Integer userId) {
        return BASE_KEY.concat(":tk:").concat(userId.toString());
    }


    public static String getCaptchaCacheKey(@NotNull String receiver, String typeJson) {
        return BASE_KEY.concat(":cp:").concat(receiver).concat(typeJson);
    }

    /**
     * 获取公用缓存
     *
     * @param keyFor 缓存类别
     * @return key
     */
    public static String getPublicCacheKey(String keyFor) {
        return PUBLIC_BASE_KEY.concat(keyFor);
    }


    /**
     * 获取公用缓存
     *
     * @param keyFor 缓存类别
     * @return key
     */
    public static String getPublicCacheKey(String keyFor, String sub) {
        return PUBLIC_BASE_KEY.concat(keyFor).concat(":").concat(sub);
    }
}
